home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-19
/
surfsrc3.zip
/
GETKEY.INC
< prev
next >
Wrap
Text File
|
1991-09-14
|
757b
|
29 lines
function GETKEY: integer;
{ Wait for a single keypress from the keyboard. Valid keys are 1 thru 9. }
var c: char; { value from keypress }
Result: integer; { result of keypress }
begin
{ clear keyboard buffer }
while keypressed do
c := readkey;
{ Pause for Keypress }
c := readkey;
if (c = #0) and (keypressed) then begin { NUL character (fcn key) }
c := readkey;
{ KVC 09/05/91 Removed function key support }
Result := -1;
end else if (ord(c) = 32) or (ord(c) = 27) then
{ Treat a spacebar or escape like a 0 }
Result := 0
else
Result := ord(c) - 48;
if (Result >= 0) and (Result < 10) then
Getkey := Result
else
Getkey := -1;
end; { function GETKEY }